Ext.define('Oa.view.supplier.FileUpdatePanel',{
    extend:'Ext.form.Panel',
    alias:'widget.update',
    width:"100%",
    height:100,
    title:'资质证书上传',
    enctype:'multipart/form-data', 
    fileUpload: true,
    autoScroll:true,
    fieldDefaults: {
            labelAlign: 'right',
            labelWidth: 100,
            msgTarget: 'under'
    },
    defaults:{
        margin:"10 0 0 5",
        width:250,
        disabled:true
    },
    items:[{
            xtype:'textfield',
            name:'fileName',
            id:'fileName',
            disabled:false,
            hidden:true
   },{
            xtype:'textfield',
            name:'id',
            disabled:false,
            hidden:true
   },{
            itemId:'file',
            xtype: 'fileuploadfield',
            msgTarget : 'side',
            id:'file',
            name:'file',
            emptyText: '请选择文件...',   
            fieldLabel: '资质文件'
   }],
   buttons:[{
        text:'上传',
        id:'updateBtn',
        disabled:true,
        handler: function(obj){
                var form = this.up('form').getForm();
                var fileFullName = Ext.getCmp("file").value;
                Ext.getCmp('fileName').setValue(fileFullName);
                if(fileFullName!=null&&fileFullName!=""){
                    Ext.MessageBox.show({
                      title:'警告',
                      msg:'若已经存在文件，该操作会覆盖原文件确定上传？',
                      buttons:Ext.Msg.YESNO,
                      icon:Ext.Msg.WARNING,
                      fn:function(is){
	                       if(is=='yes'){
	                            form.submit({
			                          url: '../supplierAction/file.do',
			                          success:function(){
			                          Ext.getCmp('file').setDisabled(true);
			                          obj.setDisabled(true);
			                          Ext.getCmp('supplierGrid').store.load();
                                      Ext.MessageBox.alert("提示","上传成功！");
			                          },
			                          failure:function(){
                                        Ext.MessageBox.alert("提示","上传失败！<br>请确定上传文件不能大于9M");
			                         }
			                     });          
	                        }
                        }
                     });
                     }else{
                        Ext.MessageBox.alert("提示","请选择文件后再上传！");                    
                     }
            }
   }] 
})